package com.code.google.mdsc.gui.i18n;

import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;

import com.code.google.mdsc.io.log.SimpleLogger.LogMode;
import com.code.google.mdsc.io.log.impl.SimpleLoggerImpl;

public class Messages {
	private static final String BUNDLE_NAME = "com.code.google.mdsc.gui.i18n.messages";
	private static ResourceBundle ressourceBundle;

	static {
		try {
			ressourceBundle = ResourceBundle.getBundle(BUNDLE_NAME,
					Locale.getDefault());
		} catch (MissingResourceException e) {
			SimpleLoggerImpl.getInstance().log(LogMode.ERROR, e.getMessage());
		}
	}

	private Messages() {
	}

	public static String getString(String key) {
		try {
			if (ressourceBundle == null)
				return '!' + key + '!';
			return ressourceBundle.getString(key);
		} catch (MissingResourceException e) {
			SimpleLoggerImpl.getInstance().log(LogMode.ERROR, e.getMessage());
			return '!' + key + '!';
		}
	}
}
